package touche.touche;

import model.GameManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class EndGameActivity extends Activity implements View.OnClickListener {
	private Button _buttonNewGame;
	private Button _buttonSendScore;
	private Button _buttonMenu;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.e("EndGameActivity", "onCreate");

		setContentView(R.layout.end_game);

		_buttonNewGame = (Button) findViewById(R.id.buttonNewGame);
		_buttonNewGame.setOnClickListener(this);

		_buttonSendScore = (Button) findViewById(R.id.buttonSendScore);
		_buttonSendScore.setOnClickListener(this);

		_buttonMenu = (Button) findViewById(R.id.buttonMenu);
		_buttonMenu.setOnClickListener(this);

		Intent thisIntent = getIntent();
		TextView textViewTitle = (TextView) findViewById(R.id.textViewLevel);
		textViewTitle.setText(thisIntent.getExtras().getString("levelName"));

		TextView textViewScore = (TextView) findViewById(R.id.textViewScore);
		textViewScore.setText(new String(String.valueOf(thisIntent.getExtras()
				.getInt("score"))));

	}

	public void onClick(View v) {
		if (_buttonNewGame == v) {
			GameManager.getInstance().start(this);
			finish();
		} else if (_buttonSendScore == v) {
			startActivity(new Intent(EndGameActivity.this,
					SendScoreActivity.class));
			finish();
		} else if (_buttonMenu == v) {
			finish();
		}
	}
}
